<HTML>

<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<TITLE>Multiple Threads with the Extractor API</TITLE>
</HEAD>

<BODY BGCOLOR="#ffffff">

<MAP NAME="banner_top">
<AREA SHAPE="rect" COORDS="588,14,620,40" 
    HREF="http://www.iit.nrc.ca/english.html">
<AREA SHAPE="rect" COORDS="538,14,583,37" 
    HREF="http://www.nrc.ca/corporate/english/">
<AREA SHAPE="rect" COORDS="86,4,421,37" 
    HREF="http://www.iit.nrc.ca/II_public/index.html">
</MAP>

<IMG SRC="banner_top.jpg" width="620" height="37" 
    alt="II Group Banner" USEMAP="#banner_top"
ISMAP border="0"><BR><IMG SRC="banner_extractor.jpg" width="217" 
    heigth="49" alt="Extractor">

<FONT COLOR="#400080"><H1>Multiple Threads with the Extractor API</H1></FONT>

<SMALL><I>Extractor 7.2, Revised December 4, 2001</I></SMALL><BR>
<SMALL><I>Copyright &copy; 2001, National Research Council of Canada</I></SMALL>

<HR>

<P>
The <A HREF=api.html>API for Extractor</A> allows 
several documents to be processed simultaneously,
using separate threads for each document. This is useful, for
example, when processing web pages. A major bottle-neck when
downloading web pages is waiting for web servers to respond to
requests for pages. One way around this bottle-neck is to download
several pages simultaneously, using a separate thread to process
each page.
</P>

<P>
Extractor is fully reentrant, to allow multithreading without the use of 
Win32 services such as semaphores and the EnterCriticalSection and 
LeaveCriticalSection functions. There should be a one-to-one relationship
between threads and <CODE>DocumentMemory</CODE> values, so only one thread
reads or writes to a given <CODE>DocumentMemory</CODE>. On the other hand,
there may be a many-to-one relationship between threads and
<CODE>StopMemory</CODE> values. That is, many threads may simultaneously
read one <CODE>StopMemory</CODE>. 
</P>

<P>
Most functions that take <CODE>StopMemory</CODE> as an argument only
read <CODE>StopMemory</CODE>; they do not write. This is why many threads
can safely access the same <CODE>StopMemory</CODE>.
However, the functions <CODE>ExtrAddStopWord</CODE> and
<CODE>ExtrAddStopPhrase</CODE> write <CODE>StopMemory</CODE>. These
two functions should be called (one after the other; not at the same
time) before any other threads access <CODE>StopMemory</CODE>. If
one thread calls <CODE>ExtrAddStopWord</CODE> or
<CODE>ExtrAddStopPhrase</CODE> with a given value of <CODE>StopMemory</CODE>
while a second thread calls any function with the same value of
<CODE>StopMemory</CODE>, the memory may become corrupted.
</P>

<HR>

<CENTER>
<table border="1" bgcolor="#ccccff">
<tr><td><font size=2>
[ <a href="http://extractor.iit.nrc.ca/">Extractor Home</a> |
<A HREF="http://www.iit.nrc.ca/II_public/french.html">Fran&ccedil;ais</a> |
<A HREF="http://www.iit.nrc.ca/english.html">IIT</A> |
<A HREF="http://www.iit.nrc.ca/II_public/index.html">II Group</A> |
<A HREF="http://www.nrc.ca/corporate/english/">NRC</A> |
<A HREF="http://ai.iit.nrc.ca/search.html">Search</A> |
<A HREF="mailto:Peter.Turney@nrc.ca">Feedback</A> ]
[ <I>Updated</I>: December 4, 2001 ]</font size=2></td></tr>
</table>
</CENTER>

</BODY>
</HTML>
